using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Design;

namespace Acms.WebControls
{
    public abstract class BaseColumn : WebControl
    {
        private bool _IncludeInnerDiv = true;

        public bool IncludeInnerDiv
        {
            get { return _IncludeInnerDiv; }
            set { _IncludeInnerDiv = value; }
        }

        protected abstract string GetClass();

        internal abstract int GetColumnWidth();

        protected override void Render(HtmlTextWriter writer)
        {
            AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, GetClass());
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (IncludeInnerDiv)
            {
                AddInnerAttributesToRender(writer);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "InnerColumn");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
            }
            RenderChildren(writer);

            if (IncludeInnerDiv)
            {
                writer.RenderEndTag();
            }

            writer.RenderEndTag();
        }

        protected virtual void AddInnerAttributesToRender(HtmlTextWriter writer)
        {
        }

    }

    public abstract class BaseColumnDesigner : ContainerControlDesigner
    {
        private Style _Style;
        public override Style FrameStyle
        {
            get
            {
                if (_Style == null)
                {
                    _Style = new Style();
                    _Style.Width = Unit.Percentage(25);
                    _Style.Font.Name = "Verdana";
                    _Style.Font.Size = new FontUnit("Small");
                    _Style.BackColor = Color.LightGray;
                    _Style.ForeColor = Color.Black;
                }
                return _Style;
            }
        }
    }

}
